<?php


abstract class BaseEmpresa extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $cp_empresa;


	
	protected $nombre_empresa;


	
	protected $direccion;


	
	protected $cf_ciudad;


	
	protected $cargo;


	
	protected $sueldo;


	
	protected $tipo_empresa;


	
	protected $estatus;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getCpEmpresa()
	{

		return $this->cp_empresa;
	}

	
	public function getNombreEmpresa()
	{

		return $this->nombre_empresa;
	}

	
	public function getDireccion()
	{

		return $this->direccion;
	}

	
	public function getCfCiudad()
	{

		return $this->cf_ciudad;
	}

	
	public function getCargo()
	{

		return $this->cargo;
	}

	
	public function getSueldo()
	{

		return $this->sueldo;
	}

	
	public function getTipoEmpresa()
	{

		return $this->tipo_empresa;
	}

	
	public function getEstatus()
	{

		return $this->estatus;
	}

	
	public function setCpEmpresa($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->cp_empresa !== $v) {
			$this->cp_empresa = $v;
			$this->modifiedColumns[] = EmpresaPeer::CP_EMPRESA;
		}

	} 
	
	public function setNombreEmpresa($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->nombre_empresa !== $v) {
			$this->nombre_empresa = $v;
			$this->modifiedColumns[] = EmpresaPeer::NOMBRE_EMPRESA;
		}

	} 
	
	public function setDireccion($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->direccion !== $v) {
			$this->direccion = $v;
			$this->modifiedColumns[] = EmpresaPeer::DIRECCION;
		}

	} 
	
	public function setCfCiudad($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->cf_ciudad !== $v) {
			$this->cf_ciudad = $v;
			$this->modifiedColumns[] = EmpresaPeer::CF_CIUDAD;
		}

	} 
	
	public function setCargo($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->cargo !== $v) {
			$this->cargo = $v;
			$this->modifiedColumns[] = EmpresaPeer::CARGO;
		}

	} 
	
	public function setSueldo($v)
	{

		if ($this->sueldo !== $v) {
			$this->sueldo = $v;
			$this->modifiedColumns[] = EmpresaPeer::SUELDO;
		}

	} 
	
	public function setTipoEmpresa($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->tipo_empresa !== $v) {
			$this->tipo_empresa = $v;
			$this->modifiedColumns[] = EmpresaPeer::TIPO_EMPRESA;
		}

	} 
	
	public function setEstatus($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->estatus !== $v) {
			$this->estatus = $v;
			$this->modifiedColumns[] = EmpresaPeer::ESTATUS;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->cp_empresa = $rs->getString($startcol + 0);

			$this->nombre_empresa = $rs->getString($startcol + 1);

			$this->direccion = $rs->getString($startcol + 2);

			$this->cf_ciudad = $rs->getString($startcol + 3);

			$this->cargo = $rs->getString($startcol + 4);

			$this->sueldo = $rs->getFloat($startcol + 5);

			$this->tipo_empresa = $rs->getString($startcol + 6);

			$this->estatus = $rs->getString($startcol + 7);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 8; 
		} catch (Exception $e) {
			throw new PropelException("Error populating Empresa object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(EmpresaPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			EmpresaPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(EmpresaPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = EmpresaPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setCpEmpresa($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += EmpresaPeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


			if (($retval = EmpresaPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}



			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = EmpresaPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getCpEmpresa();
				break;
			case 1:
				return $this->getNombreEmpresa();
				break;
			case 2:
				return $this->getDireccion();
				break;
			case 3:
				return $this->getCfCiudad();
				break;
			case 4:
				return $this->getCargo();
				break;
			case 5:
				return $this->getSueldo();
				break;
			case 6:
				return $this->getTipoEmpresa();
				break;
			case 7:
				return $this->getEstatus();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = EmpresaPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getCpEmpresa(),
			$keys[1] => $this->getNombreEmpresa(),
			$keys[2] => $this->getDireccion(),
			$keys[3] => $this->getCfCiudad(),
			$keys[4] => $this->getCargo(),
			$keys[5] => $this->getSueldo(),
			$keys[6] => $this->getTipoEmpresa(),
			$keys[7] => $this->getEstatus(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = EmpresaPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setCpEmpresa($value);
				break;
			case 1:
				$this->setNombreEmpresa($value);
				break;
			case 2:
				$this->setDireccion($value);
				break;
			case 3:
				$this->setCfCiudad($value);
				break;
			case 4:
				$this->setCargo($value);
				break;
			case 5:
				$this->setSueldo($value);
				break;
			case 6:
				$this->setTipoEmpresa($value);
				break;
			case 7:
				$this->setEstatus($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = EmpresaPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setCpEmpresa($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setNombreEmpresa($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setDireccion($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setCfCiudad($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setCargo($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setSueldo($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setTipoEmpresa($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setEstatus($arr[$keys[7]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(EmpresaPeer::DATABASE_NAME);

		if ($this->isColumnModified(EmpresaPeer::CP_EMPRESA)) $criteria->add(EmpresaPeer::CP_EMPRESA, $this->cp_empresa);
		if ($this->isColumnModified(EmpresaPeer::NOMBRE_EMPRESA)) $criteria->add(EmpresaPeer::NOMBRE_EMPRESA, $this->nombre_empresa);
		if ($this->isColumnModified(EmpresaPeer::DIRECCION)) $criteria->add(EmpresaPeer::DIRECCION, $this->direccion);
		if ($this->isColumnModified(EmpresaPeer::CF_CIUDAD)) $criteria->add(EmpresaPeer::CF_CIUDAD, $this->cf_ciudad);
		if ($this->isColumnModified(EmpresaPeer::CARGO)) $criteria->add(EmpresaPeer::CARGO, $this->cargo);
		if ($this->isColumnModified(EmpresaPeer::SUELDO)) $criteria->add(EmpresaPeer::SUELDO, $this->sueldo);
		if ($this->isColumnModified(EmpresaPeer::TIPO_EMPRESA)) $criteria->add(EmpresaPeer::TIPO_EMPRESA, $this->tipo_empresa);
		if ($this->isColumnModified(EmpresaPeer::ESTATUS)) $criteria->add(EmpresaPeer::ESTATUS, $this->estatus);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(EmpresaPeer::DATABASE_NAME);

		$criteria->add(EmpresaPeer::CP_EMPRESA, $this->cp_empresa);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getCpEmpresa();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setCpEmpresa($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setNombreEmpresa($this->nombre_empresa);

		$copyObj->setDireccion($this->direccion);

		$copyObj->setCfCiudad($this->cf_ciudad);

		$copyObj->setCargo($this->cargo);

		$copyObj->setSueldo($this->sueldo);

		$copyObj->setTipoEmpresa($this->tipo_empresa);

		$copyObj->setEstatus($this->estatus);


		$copyObj->setNew(true);

		$copyObj->setCpEmpresa(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new EmpresaPeer();
		}
		return self::$peer;
	}

} 